<template>
  <div class="player" v-if="$store.state.showplayer">
    <div class="pic" @click="goDetail">
      <img v-show='$store.state.music.songItem.picUrl' :src="$store.state.music.songItem.picUrl" alt="">
    </div>
    <div class="songname">
      <p>{{$store.state.music.songItem.songName}}</p>
      <p>{{$store.state.music.songItem.zjName}}</p>
    </div>
    <div class="playButton">
      <div class="angle" @click="pause">
        <div v-if="$store.state.pause">
          <img src="../../assets/img/rankItem/pause.svg" alt="">
        </div>
        <div v-else class="angles"></div>
      </div>
    </div>
    <audio :src="$store.state.music.url" id="audio" autoplay></audio>
  </div>
</template>
<script>
    export default {
        name: "Player",
        props:{

        },
        created() {
            // console.log(this.$store.state.music)
        },
        methods:{
            goDetail(){
                this.$router.push('/playDetail')
                this.$store.commit('hideplayer')
            },
            pause(){
              this.$store.commit('play')
              let audio = document.getElementById('audio')
              if(this.$store.state.Pause){
                  audio.play()
              }else{
                  audio.pause()
              }
            },
        }

    }
</script>

<style scoped>
  .player{
    width: 100%;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.95);;
    border-top: 1px solid #ccc;
    position: fixed;
    bottom: 0;
    display: flex;
    z-index: 100;
  }

  .pic{
    flex: 1;
    margin-left: 20px;
    margin-top: -10px;
  }

  .pic img{
    width: 50px;
    height: 50px;
    border: 0px solid #fff;
    border-radius: 25px;

    -webkit-transition-property: -webkit-transform;
    -webkit-transition-duration: 1s;
    -moz-transition-property: -moz-transform;
    -moz-transition-duration: 10s;
    -webkit-animation: rotate 10s linear infinite;
    -moz-animation: rotate 10s linear infinite;
    -o-animation: rotate 10s linear infinite;
    animation: rotate 10s linear infinite;
  }

  .songname{
    flex: 4;
    font-size: 13px;
    line-height: 43px;
    font-weight: 800;
    display: flex;
  }

  .songname p{
    margin-left: 6px;
  }

  .playButton{
    width: 15px;
    height: 15px;
    flex: 1;
    margin: auto;
  }

  .angle{
    float: left;
    width: 20px;
    height: 20px;
    border: 1px solid #000;
    border-radius: 10px;
    margin-top: -3px;
  }

  .angle img{
    width: 11px;
    margin-left: 3px;
  }

  .angles{
    border-top: 4px solid transparent;
    border-left: 6px solid #000;
    border-bottom: 4px solid transparent;
    margin-left: 6px;
    margin-top: 4px;
  }

</style>